package com.ailight.smart.ai.feign.fallbackfactory;

import com.ailight.smart.ai.command.LightModelCommand;
import com.ailight.smart.ai.feign.client.LightApiFeignClient;
import com.ailight.smart.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class lightApiFallbackFactory implements FallbackFactory<LightApiFeignClient> {

    @Override
    public LightApiFeignClient create(Throwable cause) {
        return new LightApiFeignClient() {
            @Override
            public Result<String> operationLight(LightModelCommand command) {
                log.error("light-api-fallback-factory:operationLight:{}", cause.getMessage());
                return Result.success("light-api-fallback-factory:" + cause.getMessage());
            }

            @Override
            public Result<String> modifyLightState(Integer state) {
                log.error("light-api-fallback-factory:modifyLightState:{}", cause.getMessage());
                return Result.success("light-api-fallback-factory:" + cause.getMessage());
            }
        };
    }
}
